package com.company.project.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 文件上传配置
 */
@Component
@ConfigurationProperties(prefix = "file")
public class UploadConfig {
    
    /**
     * 文件上传路径
     */
    private String path;
    
    /**
     * 获取当前操作系统的上传路径
     */
    public String getUploadPath() {
        String os = System.getProperty("os.name").toLowerCase();
        
        if (os.contains("windows")) {
            // Windows系统使用配置的路径
            return path != null ? path : "C:/files";
        } else {
            // Linux/Unix系统使用默认路径
            return "/data/files";
        }
    }
    
    /**
     * 获取电信备案图片上传路径
     */
    public String getTelecomUploadPath() {
        String basePath = getUploadPath();
        return basePath + "/telecom/";
    }
    
    public String getPath() {
        return path;
    }
    
    public void setPath(String path) {
        this.path = path;
    }
}
